import React,{Component} from 'react'
import {userData} from 'userData/userData'

import List from './components/List'
import qs from "qs"
import {ReceiptStyle} from './StyleMytask'

import {
    Route,
    withRouter,
  } from 'react-router-dom'
  import connect from 'pages/redux-component/connect'

class Receipt extends Component{
    state = {
        cateList: []
    }
    render(){
        console.log(this.state.cateList)
        return(
            <ReceiptStyle>
            {
            this.state.cateList.map((value,index)=>{
               console.log(value);   
            
            return(
                <List
                key={index}
                data={value}
                handleClick={()=>this.onhandleClick(value.tid)}
                {...this.props}
                ></List>
            )
           
            })
            }
             </ReceiptStyle>
        )
    }
    componentDidMount() {
    let result =  fetch('/Legang/task/AcceptTack',{
          
          method:"POST",
          headers:{
              "Content-type":"application/x-www-form-urlencoded"
          },
          body: qs.stringify({uid:this.props.uid})
        // "email=1486960462@qq.com&password=123456",
        })
        
        .then(response => response.json())
        .then(result => {
            console.log(result)
            if(result.flag){
                this.setState({
                    cateList: result.data
                },()=>{

                    console.log(result)

                })
            }
        })
        
        }
    
    onhandleClick(tag){
        this.props.history.push({pathname:'/myChildRouter/checkTask/' + tag})

    }
}

export default withRouter(connect(Receipt))